//
//
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 HZMengLiao. All rights reserved.
//
#import <UIKit/UIKit.h>

@interface KCycleViewLayout : NSObject

@property (nonatomic) UIEdgeInsets insets;
@property (nonatomic) CGFloat margin;
@property (nonatomic) CGSize pageSize;
@property (nonatomic) CGFloat pageCornerRadius;
@property (nonatomic) BOOL loopEnabled;
@property (nonatomic) BOOL disableClick;
@property (readonly,nonatomic) CGRect pageFrame;
//垂直方向
@property (nonatomic) BOOL vertical;
//非滚动方向可伸缩布局
@property (nonatomic) BOOL flexLayout;

- (instancetype)initWithInsets:(UIEdgeInsets)insets margin:(CGFloat)margin pageSize:(CGSize)pageSize loopEnabled:(BOOL)loopEnabled;

@end

@class KCycleView;
@protocol KCycleViewDelegate <NSObject>

- (NSInteger)numberOfPagesInCycleView:(KCycleView *)cycleView;
- (UIView *)cycleView:(KCycleView *)cycleView pageAtIndex:(NSInteger)index reusePage:(UIView *)reusePage;
@optional
- (void)cycleView:(KCycleView *)cycleView didClickPage:(UIView *)page atIndex:(NSInteger)index;
- (void)cycleView:(KCycleView *)cycleView didMoveToIndex:(NSInteger)index;
- (void)cycleView:(KCycleView *)cycleView didEndDisplayPage:(UIView *)page atIndex:(NSInteger)index;

@end

@interface KCycleView : UIView

@property (readonly,nonatomic) KCycleViewLayout * layout;

@property (strong,nonatomic) UIScrollView * scroll;

@property (weak,nonatomic) id<KCycleViewDelegate> delegate;

@property (readonly,nonatomic) NSInteger currentIndex;

@property (nonatomic) NSInteger maxPageInMemory;

@property (nonatomic) NSTimeInterval autoCycleInterval;
//本次翻页是否淡入淡出效果 可在cycleView:didMoveToIndex:代理中使用
@property (nonatomic) BOOL pageWithFade;
///左拉刷新一张图片也要滚动
@property (nonatomic,assign) BOOL hasRightRefresh;

- (instancetype)initWithFrame:(CGRect)frame layout:(KCycleViewLayout *)layout;

- (void)reloadData;

- (void)reloadDataAtIndex:(NSInteger)index;

- (UIView *)pageAtIndex:(NSInteger)index;

- (void)gotoIndex:(NSInteger)index;

- (void)nextPage;

- (void)clearData;

- (void)openFadeEffect:(BOOL)open;

- (void)openFadeEffect:(BOOL)open contentMode:(UIViewContentMode)contentMode;

- (void)setScrollEnable:(BOOL)enable;



@end
